<template>
	<view>
		<u-popup :show="show" round="24rpx" mode="center" :safeAreaInsetBottom="false" bgColor="transparent">
			<view class="popup-container">
				<view class="popup-content-box">
					<view class="popup-content">
						<view class="popup-title">送vip会员{{newDay}}天免费体验</view>
						<image src="../static/new/vip.png" class="popup-image"></image>
						<view class="popup-tips">vip可应用于 </view>
						<view class="funtion-list">
							<view class="funtion-item">
								<image src="../static/new/chat.png" class="funtion-image"></image>
								<view class="funtion-label">文字聊天</view>
							</view>
							<view class="funtion-item">
								<image src="../static/new/wechat.png" class="funtion-image"></image>
								<view class="funtion-label">查看微信</view>
							</view>
						</view>
						<button class="save-button" @click="$u.throttle(submitReceive,2000)">立即领取</button>
					</view>

				</view>
				<image class="popup-close" @click="$emit('close')" src="../static/common/icon_close.png" />
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		name: "NewPopup",
		data() {
			return {
				newDay: null
			};
		},
		props: {
			show: {
				type: Boolean,
				default: false //是否显示
			},
		},
		watch: {
			show(value) {
				if (value == true) {
					this.getAgentNewday()
				}
			},
		},
		methods: {
			submitReceive(){
				this.$Api.user.submitReceiveVip().then(res => {
					this.$Toast('领取成功')
					this.$emit('success')
				})
			},
			getAgentNewday() {
				this.$Api.user.getAgentNewday().then(res => {
					this.newDay = res.data
				})
			}
		}

	}
</script>

<style lang="scss" scoped>
	.popup-container {
		// background-color: #ffffff;
		position: relative;

		.popup-content-box {
			width: 612rpx;
			height: 958rpx;
			background-image: url("../static/new/new-bg.png");
			background-size: 100% 100%;
			border-radius: 24rpx 24rpx 0 0;
			text-align: center;
			position: relative;

			.popup-content {
				position: absolute;
				top: 400rpx;
				left: 50%;
				transform: translateX(-50%);

				.popup-title {
					font-size: 32rpx;
					color: #FE6600;

				}

				.popup-image {
					font-size: 32rpx;
					color: #FE6600;
					width: 412rpx;
					height: 182rpx;
					margin-top: 24rpx;
				}

				.popup-tips {
					font-size: 28rpx;
					color: #9A9A9A;
					margin-top: -22rpx;
				}

				.funtion-list {
					margin: 20rpx 124rpx 0;
					display: flex;
					align-items: center;
					justify-content: space-between;

					.funtion-item {
						text-align: center;

						.funtion-image {
							width: 48rpx;
							height: 48rpx;
						}

						.funtion-label {
							font-weight: 400;
							font-size: 28rpx;
							color: #9A9A9A;
							margin-top: 12rpx;
						}
					}
				}
			}

		}

		.popup-close {
			width: 80rpx;
			height: 80rpx;
			margin: 40rpx auto 0;
			display: flex;
			background-color: #ffffff;
			border-radius: 50%;
			align-items: center;
			justify-content: center;
		}

		.save-button {
			width: 522rpx;
			height: 88rpx;
			background: linear-gradient(0deg, #FF6A00 0%, #FFC210 100%);
			box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(254, 102, 0, 0.3);
			font-weight: bold;
			font-size: 30rpx;
			color: #FFFFFF;
			text-align: center;
			line-height: 88rpx;
			border-radius: 44rpx;
			margin-top: 38rpx;

			&::after {
				border: none;
			}
		}
	}
</style>